package com.brook.app.android.filepicker.ui;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;

import com.brook.app.android.filepicker.R;

/**
 * @author Brook
 * @time 2020-03-14 10:58
 * {@hide}
 */
public class FilePickerActivity extends AppCompatActivity {

    public static final String CONFIG_TOKEN = "config_token";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.filepicker_activity_simple);

        long token = getIntent().getLongExtra(CONFIG_TOKEN, 0);
        if (token <= 0) {
            finish();
            return;
        }

        FragmentManager supportFragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.content, FilePickerFragment.newInstance(token));
        fragmentTransaction.commitNowAllowingStateLoss();
    }
}
